<?php
$this->breadcrumbs=array(
	'Orders'=>array('index'),
	$model->orderid,
);

$this->menu=array(
	array('label'=>'List Orders', 'url'=>array('index')),
	array('label'=>'Create Orders', 'url'=>array('create')),
	array('label'=>'Update Orders', 'url'=>array('update', 'id'=>$model->orderid)),
	array('label'=>'Delete Orders', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->orderid),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Orders', 'url'=>array('admin')),
);
?>

<h1>View Orders #<?php echo $model->orderid; ?></h1>

<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
    <tr>
        <th rowspan="3" class="sized"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/images/shared/side_shadowleft.jpg" width="20" height="300" alt="" /></th>
        <th class="topleft"></th>
        <td id="tbl-border-top">&nbsp;</td>
        <th class="topright"></th>
        <th rowspan="3" class="sized"><img src="<?php echo Yii::app()->theme->baseUrl; ?>/images/shared/side_shadowright.jpg" width="20" height="300" alt="" /></th>
    </tr>
    <tr>
        <td id="tbl-border-left"></td>
        <td>
            <!--  start content-table-inner -->
            <div id="content-table-inner">

                <table border="0" width="100%" cellpadding="0" cellspacing="0">
                    <tr valign="top">
                        <td>
                            <table border="0" cellpadding="2" cellspacing="3" width="100%">
                                <tr>
                                    <th align="left" width="80">Order ID: </th>
                                    <td  align="left" width="120"><?php echo $order->orderid; ?></td>
                                    <th  align="left" width="80">Order Note: </th>
                                    <td rowspan="3"><textarea rows="5" cols="30" readonly></textarea></td>
                                </tr>
                                <tr>
                                    <th  align="left" >Order Date: </th>
                                    <td><?php echo date('d-m-Y H:i:s', $order->orderdate); ?></td>
                                </tr>
                                <tr>
                                    <th  align="left">User: </th>
                                    <td><?php echo $order->user->username; ?></td>
                                </tr>                               
                            </table>
                            <br/>
                            <table border="0" cellpadding="2" cellspacing="3" width="100%" class="padded-table">
                                <tr>
                                    <th>Drink Name</th>
                                    <th>Amount</th>
                                    <th>Add On Syrup</th>
                                    <th>Total Syrup Prices</th>
                                    <th>Price</th>
                                </tr>
                                <?php
                                    $syrupprice = 0;
                                    $totalPrice = 0;
                                    $toalSyrup = 0;
                                    
                                    foreach ($orderDetail as $detail => $value):
                                        $syrupPrice += menuService::getSyrupNameByID($value->syrupid1, true) + menuService::getSyrupNameByID($value->syrupid2, true);
                                        $manyDrinks = $value->total > 1 ? " x ".$value->total : " x 1";
                                        $totalPrice += (int)($value->price) * (int)($value->total);
                                        $toalSyrup += $syrupPrice;
                                        echo CHtml::openTag('tr', array('align' => 'center'));
                                        echo CHtml::tag('td', array(), $value->drinkname, true);
                                        echo CHtml::tag('td', array(), $value->total, true);
                                        echo CHtml::tag('td', array(), menuService::getSyrupNameByID($value->syrupid1)."  -  ".menuService::getSyrupNameByID($value->syrupid2), true);
                                        echo CHtml::tag('td', array(), number_format($syrupPrice, 0, '', ' '), true);
                                        echo CHtml::tag('td', array(), number_format($value->price, 0, '', ' ') . $manyDrinks, true);
                                        echo CHtml::closeTag('tr');
                                    endforeach;
                                ?>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td align="center"><?php echo number_format($toalSyrup, 0, '', ' '); ?></td>
                                    <td align="center"><?php echo number_format($totalPrice, 0, '', ' '); ?></td>
                                </tr>
                                <tr>
                                    <td colspan="5" align="right" style="padding-right: 20px"><span class="total">Total: <?php echo number_format(($toalSyrup+$totalPrice), 0, '', ' ') . " VNĐ"; ?></span></td>
                                </tr>
                            </table>
                        </td>                        
                    </tr>                    
                </table>

                <div class="clear"></div>


            </div>
            <!--  end content-table-inner  -->
</td>
<td id="tbl-border-right"></td>
</tr>
<tr>
	<th class="sized bottomleft"></th>
	<td id="tbl-border-bottom">&nbsp;</td>
	<th class="sized bottomright"></th>
</tr>
</table>